﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Networking;
using Windows.Networking.Sockets;
using Windows.Storage.Streams;

namespace TestApp
{
    

    class networkAccess
    {
        DataWriter writer = null;
        //movements move = new movements();
        private DatagramSocket mySocket;



        public networkAccess()
        {
            mySocket = new DatagramSocket();
        }

        public async void connect (HostName remoteHost, string port)
        {
            await mySocket.ConnectAsync(remoteHost, port);
        }
        public async void sendData(string data)
        {
            if (App.allSet == true)
            {

                if (writer == null)
                {

                    var stream = mySocket.OutputStream;
                    writer = new DataWriter(stream);
                }

                writer.WriteString(data);

                await writer.StoreAsync();
            }

        }

        //public async void sendData(movements data)
        //{
        //    if (writer == null)
        //    {
        //        var stream = mySocket.OutputStream;
        //        writer = new DataWriter(stream);
        //    }

          //  byte[] send =

           // writer.WriteInt16(data);

               // await writer.StoreAsync();

               // writer.Dispose();

           

        }

    }

